<template>
  <van-popup v-model="showDialog">
    <div class="dialog-wrap">
      <div class="dialog-title">{{ title }}</div>
      <div class="dialog-content">
        {{ content }}
      </div>
      <div class="footer">
        <div class="btn" @click="handleClose" v-if="showCancelText">
          {{ cancelText }}
        </div>
        <div class="btn" @click="handleSure" :style="{ color: okTextColor }">
          {{ okText }}
        </div>
      </div>
    </div>
  </van-popup>
</template>

<script>
export default {
  name: 'confirmPopup',
  props: {
    title: {
      type: String,
      default: '温馨提示'
    },
    content: {
      type: String,
      default: '您存在未支付的商品订单，请支付完成后再进行充值操作'
      // 请稍后在我的订单中查询订单状态
    },
    cancelText: {
      type: String,
      default: '取消'
    },
    okText: {
      type: String,
      default: '确定'
    },
    showCancelText: {
      type: Boolean,
      default: true
    },
    showOkText: {
      type: Boolean,
      default: true
    },
    okTextColor: {
      type: String,
      default: '#333'
    }
  },
  data() {
    return {
      showDialog: false
    };
  },
  methods: {
    handleClose() {
      this.showDialog = false;
      this.$emit('onCancel');
    },
    handleSure() {
      this.showDialog = false;
      this.$emit('onOk');
    }
  }
};
</script>

<style lang="scss" scoped>
.dialog-wrap {
  width: 301px;
  background-color: #fff;
  border-radius: 10px;
  .dialog-title {
    font-size: 18px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    color: #333;
    line-height: 25px;
    padding-top: 20px;
    margin-bottom: 10px;
    text-align: center;
  }

  .dialog-content {
    width: 265px;
    margin: 0 auto 22px;
    font-size: 14px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    text-align: center;
  }

  .footer {
    height: 49px;
    display: flex;
    border-top: 1px solid #f0f0f0;
    .btn {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      font-weight: 400;
      font-size: 18px;
      font-family: PingFangSC-Regular;
      border-right: 1px solid #f0f0f0;
      color: #333;
      &:last-child {
        border-right: none;
      }
    }
  }
}

.van-popup {
  background-color: transparent;
  border-radius: 0;
}
</style>
